import os_client_config
from keystoneclient.v3 import client as ksclient
# cc=os_client_config.OpenStackConfig('./config.yaml').get_one_cloud('devstack3')
from keystoneauth1.identity import v3
from novaclient.v2 import client
from keystoneauth1 import session
from keystoneauth1 import session
import os
"""
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=Centos123
export OS_AUTH_URL=http://controller01:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
"""

os.environ["OS_USERNAME"] = 'admin'
os.environ["OS_PASSWORD"] = 'Centos123'
os.environ["OS_AUTH_URL"] = 'http://controller01:35357/v3'
os.environ["OS_PROJECT_NAME"] = 'admin'
os.environ["OS_IDENTITY_API_VERSION"] = '3'
os.environ["OS_PROJECT_DOMAIN_NAME"] = 'Default'
os.environ["OS_USER_DOMAIN_NAME"] = "Default"

auth = v3.Password(user_domain_name=os.environ["OS_USER_DOMAIN_NAME"],
                username='admin',
                password='Centos123',
                project_domain_name=os.environ["OS_PROJECT_DOMAIN_NAME"],
                project_name=os.environ["OS_PROJECT_NAME"],
                auth_url=os.environ["OS_AUTH_URL"])
sess = session.Session(auth=auth)
print sess
keystone = ksclient.Client(session=sess)
print keystone.auth_token
from novaclient import client as nvclient
nova = nvclient.Client('2', session=sess)
print nova.servers.list()


